package com.woniu.park.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniu.park.controller.form.ParkspaceForm;
import com.woniu.park.entity.Parkspace;
import com.woniu.park.dao.ParkspaceMapper;
import com.woniu.park.service.IParkspaceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.park.util.Result;
import com.woniu.park.util.Status;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cxb
 * @since 2020-09-05
 */
@Service
@Slf4j
public class ParkspaceServiceImpl extends ServiceImpl<ParkspaceMapper, Parkspace> implements IParkspaceService {

    @Autowired
    private ParkspaceMapper parkspaceMapper;
    @Override
    public void insertPark(Parkspace parkspace) {
        parkspaceMapper.insert(parkspace);
    }

    /*查询可用车位*/
    @Override
    public List<Parkspace> freeParking() {
        QueryWrapper<Parkspace> wrapper = new QueryWrapper<>();
        wrapper.eq("parkspace_status",1);
        return parkspaceMapper.selectList(wrapper);
    }


    /*
        查询所有车位
     */
    @Override
    public  List<Parkspace> findPark() {
        List<Parkspace> parkspaces = parkspaceMapper.selectList(null);
        log.info("附近所有车位:{}",parkspaces);
        return parkspaces;
    }

    @Override
    public Parkspace selecrParkspace(int parkspaceId) {
        Parkspace parkspace = parkspaceMapper.selectById(parkspaceId);
        return parkspace;
    }

}
